package com.example.demo.study.exception;

import java.util.InputMismatchException;
import java.util.Scanner;

// exception 异常处理

public class Study2 {
    public void show() throws InputMismatchException {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个数：");
       Integer divisor = scanner.nextInt();
       if(divisor instanceof Integer){
           System.out.println("数是：" + divisor);
       }else{
           throw new InputMismatchException("输入的不是数字");
       }
    }
    public static void main(String[] args) {
        Study2 study = new Study2();
        Boolean flag = true;
        do{
            try {
                study.show();
                flag = false;
            }catch (InputMismatchException e){
                System.out.println("程序出现异常：" + e.getMessage());
            }finally{
                System.out.println("程序继续执行");
            }
        }while (flag);

    }
}
